package com.cf.ch4.expr;

/****
 *
 * @Author zhu-mingming
 * @Description
 * @Date 2019/2/28
 *
 **/

import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;

public class Test {
    public static void main(String[] args) throws Exception {
        // 从标准输入创建 CharStream
        ANTLRInputStream input = new ANTLRInputStream(System.in);

        // 创建 lexer，处理输入的 CharStream
        ExprLexer lexer = new ExprLexer(input);

        // 创建 buffer of tokens，保存 lexer 生成的 token
        CommonTokenStream tokens = new CommonTokenStream(lexer);

        // 创建 parser，处理 token 缓冲区中的 token
        ExprParser parser = new ExprParser(tokens);

        ParseTree tree = parser.prog();
        System.out.println(tree.toStringTree(parser));

    }
}